package com.xbstar.datafusion.util;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;

/**
 * Created by jiwenfei on 2018/1/30 16:22 .
 * 用于物 管理
 */
@Service
public class ObjectManage {
    /***
     * {
     *     id:"wwswewewe",
     *     name:"dwwewew",
     *     key:"3232",
     *     fromTime:230230202323,
     *     state:232323242,//最近的时间
     *     curSendMsg:{
     *         sdsdd
     *     },
     *     curReceiveMsg:{
     *
     *     },
     *     ip:"192.168.1.151",
     *
     * }
     */
    /**
     * 根据id更新物-状态
     * @param id
     */
    public void updateObjectById(String id){

    }

    /**
     * 新增一个影子
     * @param objectDomain
     * @return 返回该影子对应的key
     */
    public String  insertNewObject(ObjectDomain objectDomain){
        /**
         * 初始化objectDomain，注意fromeTime和state的变化
         */
        return  "key";
    }

    /**
     * 物体/系统发送消息后更新状态
     * @param id
     * @param sendMsg 物体发送的消息内容
     */
    public void updateObjectBySendMsg( String id, JSONObject sendMsg){

    }

    /**
     * 物体/系统接收消息后更新状态
     * @param id
     * @param receiveMsg 物体接收消息的内容
     */
    public void updateObjectByReceiveMsg( String id, JSONObject receiveMsg){

    }
    /**
     * 判断影子是否存活
     * @param receiveId
     * @return
     */
	public boolean canReceive(String receiveId) {
		// TODO Auto-generated method stub
		return false;
	}
}
